<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .container {
            width: 50%;
            /* 该元素真实高度为0，我们看到的只是它往下偏移而露出的padding背景色 */
            /* padding-top后的百分比以父容器**宽度**为准 */
            padding-top: 50%;
            height: 0;

            top: 50%;
            left: 50%;
            position: absolute;
            transform: translate(-50%, -50%);
            background-color: antiquewhite;
        }
    </style>
</head>
<body>
<div class="container">
</div>
</body>
</html>
